package com.ruoyi.project.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.domain.ProProcess;
import com.ruoyi.project.mapper.ProProcessMapper;
import com.ruoyi.project.service.IProProcessService;

/**
 * 项目进度Service业务层处理
 * 
 * @author phil
 * @date 2020-06-02
 */
@Service
public class ProProcessServiceImpl implements IProProcessService{
	@Autowired
	private ProProcessMapper proProcessMapper;

	/**
	 * 查询项目进度
	 * 
	 * @param processId 项目进度ID
	 * @return 项目进度
	 */
	@Override
	public ProProcess selectProProcessById(Long processId){
		return proProcessMapper.selectProProcessById(processId);
	}

	/**
	 * 查询项目进度列表
	 * 
	 * @param proProcess 项目进度
	 * @return 项目进度
	 */
	@Override
	public List<ProProcess> selectProProcessList(ProProcess proProcess){
		return proProcessMapper.selectProProcessList(proProcess);
	}

	/**
	 * 新增项目进度
	 * 
	 * @param proProcess 项目进度
	 * @return 结果
	 */
	@Override
	public int insertProProcess(ProProcess proProcess){
		proProcess.setCreateTime(DateUtils.getNowDate());
		return proProcessMapper.insertProProcess(proProcess);
	}

	/**
	 * 修改项目进度
	 * 
	 * @param proProcess 项目进度
	 * @return 结果
	 */
	@Override
	public int updateProProcess(ProProcess proProcess){
		proProcess.setUpdateTime(DateUtils.getNowDate());
		return proProcessMapper.updateProProcess(proProcess);
	}

	/**
	 * 删除项目进度对象
	 * 
	 * @param ids 需要删除的数据ID
	 * @return 结果
	 */
	@Override
	public int deleteProProcessByIds(String ids){
		return proProcessMapper.deleteProProcessByIds(Convert.toStrArray(ids));
	}

	/**
	 * 删除项目进度信息
	 * 
	 * @param processId 项目进度ID
	 * @return 结果
	 */
	@Override
	public int deleteProProcessById(Long processId){
		return proProcessMapper.deleteProProcessById(processId);
	}

	@Override
	@Transactional
	public int insertProProcess(List<ProProcess> processList){
		int resultCount = 0;
		if(processList != null && processList.size() > 0){
			for(ProProcess process : processList){
				resultCount += proProcessMapper.insertProProcess(process);
			}
		}
		return resultCount;
	}
}
